#pragma once

#include <string>
#include <system_error>

namespace helper {
namespace sqlite {

class IResult {
public:
  explicit IResult(const std::error_code & ec) : _ec(ec){}
  virtual ~IResult(){}

  IResult(IResult && other): _ec(std::move(other._ec)){
    other._ec.clear();
  }

  IResult & operator = (IResult && other);

  virtual bool isOk() const = 0;
  virtual std::string what() const;

  const std::error_code & errorCode() const {
    return _ec;
  }
  std::error_code & errorCode() {
    return _ec;
  }

protected:
  virtual int fetchCode() const;

  std::error_code _ec;
};

inline IResult & IResult::operator = (IResult && other){
  _ec = std::move(other._ec);
  other._ec.clear();
  return *this;
}

}//namespace sqlite
}//namespace helper
